component
ExtDirect="true"
{
	public any function getSelectedDatasource(required string page,required string start, required string limit, required any sort, required any filter) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			dsource = EntityLoad("EGRGEVIEWDATASOURCE");
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['DATASOURCECODE'] = dsource[i].getDATASOURCECODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['DATASOURCENAME'] = dsource[i].getDATASOURCENAME(); 
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	public any function getSelectedTable(required string page,required string start, required string limit, required any sort, required any filter) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			dsource = EntityLoad("EGRGEVIEWTABLES");
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWTABLECODE'] = dsource[i].getEVIEWTABLECODE();
				tmpresult['DATASOURCECODEFK'] = dsource[i].getDATASOURCECODEFK();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK(); 
				tmpresult['TABLENAME'] = dsource[i].getTABLENAME(); 
				tmpresult['TABLEALIAS'] = dsource[i].getTABLEALIAS();
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	
	public any function getSelectedField(required string page,required string start, required string limit, required any sort, required any filter) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			dsource = EntityLoad("EGRGEVIEWFIELDS");
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWFIELDCODE'] = dsource[i].getEVIEWFIELDCODE();
				tmpresult['EVIEWTABLECODEFK'] = dsource[i].getEVIEWTABLECODEFK();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK(); 
				tmpresult['FIELDNAME'] = dsource[i].getFIELDNAME(); 
				tmpresult['FIELDALIAS'] = dsource[i].getFIELDALIAS();
				tmpresult['PRIORITYNO'] = dsource[i].getPRIORITYNO();
				tmpresult['AGGREGATEFUNC'] = dsource[i].getAGGREGATEFUNC();
				tmpresult['DATEANDSTRINGFUNC'] = dsource[i].getDATEANDSTRINGFUNC();
				tmpresult['NUMBERFORMAT'] = dsource[i].getNUMBERFORMAT();
				tmpresult['ISDISTINCT'] = dsource[i].getISDISTINCT();
				tmpresult['WRAPON'] = dsource[i].getWRAPON();
				tmpresult['SUPPRESSZERO'] = dsource[i].getSUPPRESSZERO();
				tmpresult['OVERRIDESTATEMENT'] = dsource[i].getOVERRIDESTATEMENT(); 
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	
	public struct function getSelectedOrderBy(required string page, required string start, required string limit, required any sort, required any filter) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			dsource = EntityLoad("EGRGEVIEWORDERBY");
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWORDERBYCODE'] = dsource[i].getEVIEWORDERBYCODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['PRIORITYNO'] = dsource[i].getPRIORITYNO(); 
				tmpresult['FIELDNAME'] = dsource[i].getFIELDNAME(); 
				tmpresult['DISPLAY'] = dsource[i].getDISPLAY();
				tmpresult['ASCORDESC'] = dsource[i].getASCORDESC();
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	public struct function getGroupBy(required string page, required string start, required string limit, required any sort, required any filter, required string eviewcode) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			if(eviewcode != "_") {
				dsource = EntityLoad("EGRGEVIEWGROUPBY",{EVIEWCODEFK=#eviewcode#},"PRIORITYNO ASC");
			} else {
				dsource = EntityLoad("EGRGEVIEWGROUPBY");
			}
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWGROUPBYCODE'] = dsource[i].getEVIEWGROUPBYCODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['GROUPBYCOLUMN'] = dsource[i].getGROUPBYCOLUMN(); 
				tmpresult['PRIORITYNO'] = dsource[i].getPRIORITYNO();
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	
	public struct function getGroupByHaving(required string page, required string start, required string limit, required any sort, required any filter, required string eviewcode) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			if(eviewcode != "_") {
				dsource = EntityLoad("EGRGEVIEWHAVING",{EVIEWCODEFK=#eviewcode#},"PRIORITYNO ASC");
			} else {
				dsource = EntityLoad("EGRGEVIEWHAVING");
			}
			
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWHAVINGCODE'] = dsource[i].getEVIEWHAVINGCODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['CONJUNCTIVEOPERATOR'] = dsource[i].getCONJUNCTIVEOPERATOR(); 
				tmpresult['AGGREGATECOLUMN'] = dsource[i].getAGGREGATECOLUMN();
				tmpresult['CONDITIONOPERATOR'] = dsource[i].getCONDITIONOPERATOR();
				tmpresult['AGGREGATEVALUE'] = dsource[i].getAGGREGATEVALUE();
				tmpresult['DISPLAY'] = dsource[i].getDISPLAY();
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	} 
	
	public struct function getJoinedTables(required string page, required string start, required string limit, required any sort, required any filter, required string eviewcode) 
	ExtDirect="true"
	{
		try
        {
        	
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			if(eviewcode != "_") {
				dsource = EntityLoad("EGRGEVIEWJOINEDTABLES",{EVIEWCODEFK=#eviewcode#},"PRIORITYNO ASC");
			} else {
				dsource = EntityLoad("EGRGEVIEWJOINEDTABLES");
			}
			
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWJOINEDTABLECODE'] = dsource[i].getEVIEWJOINEDTABLECODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['JOINOPERATOR'] = dsource[i].getJOINOPERATOR();
				tmpresult['PRIORITYNO'] = dsource[i].getPRIORITYNO();
				tmpresult['TABLENAME'] = dsource[i].getTABLENAME();
				tmpresult['ONCOLUMN'] = dsource[i].getONCOLUMN();
				tmpresult['EQUALTOCOLUMN'] = dsource[i].getEQUALTOCOLUMN();
				tmpresult['DISPLAY'] = dsource[i].getDISPLAY();
				
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	
	public struct function getCondition(required string page, required string start, required string limit, required any sort, required any filter, required string eviewcode) 
	ExtDirect="true"
	{
		try
        {
			rootstruct = StructNew();
			tmpresult = StructNew();
			resultArr = ArrayNew(1);
			
			if(eviewcode != "_") {
				dsource = EntityLoad("EGRGEVIEWCONDITION",{EVIEWCODEFK=#eviewcode#},"PRIORITYNO ASC");
			} else {
				dsource = EntityLoad("EGRGEVIEWCONDITION");
			}
			
			
			for(i=1; i<=ArrayLen(dsource); i++) {
				tmpresult = StructNew();
				tmpresult['EVIEWCONDITIONCODE'] = dsource[i].getEVIEWCONDITIONCODE();
				tmpresult['EVIEWCODEFK'] = dsource[i].getEVIEWCODEFK();
				tmpresult['PRIORITYNO'] = dsource[i].getPRIORITYNO();
				tmpresult['CONJUNCTIVEOPERATOR'] = dsource[i].getCONJUNCTIVEOPERATOR();
				tmpresult['ONCOLUMN'] = dsource[i].getONCOLUMN();
				tmpresult['CONDITIONOPERATOR'] = dsource[i].getCONDITIONOPERATOR();
				tmpresult['COLUMNVALUE'] = dsource[i].getCOLUMNVALUE();
				tmpresult['DISPLAY'] = dsource[i].getCONJUNCTIVEOPERATOR() & " " & dsource[i].getONCOLUMN() & " " & dsource[i].getCONDITIONOPERATOR() & " " & dsource[i].getCOLUMNVALUE();
				
				ArrayAppend(resultArr,tmpresult);
			}
			
			rootstuct['totalCount'] = ArrayLen(dsource);
			rootstuct['topics'] = resultArr; 
			return rootstuct;
        }
        catch(Any e)
        {
        	return e;
        }

	}
	
	
}